<?php
@session_start();
require_once('../config/config.php');
require_once('../utils/CommonUtils.php');
require_once('../utils/DBUtils.php');
include ("../utils/Constants.php");
require_once('../utils/BaseDAO.php');
require("../utils/Session.php");

$commonUtils = new CommonUtils();
$baseDAO = new BaseDAO();
$contentId = $commonUtils->getParameter("id");
$returnRes = array();
$comments = $baseDAO->getItems("comment", array("id", "content", "createddate", "createdby"), "status = 1 and contentid = " . $contentId, "order by createddate desc");
$userid = Session::get('userid');
?>
<?php foreach($comments as $comment){?>
<div class="comment">
	<span id="author"><?php echo $comment['createdby'] == null ? 'Không tên' : $comment['createdby'];?></span>
	<span id="comment"><?php echo $comment['content'];?></span>
	<?php if(isset($userid) && $comment['createdby_id'] == $userid){?>
		<span id="del"><a onclick="delcomment(<?php echo $comment['id'];?>);"><img src="../css/images/delete.png"/></a></span>
	<?php }?>
	<span id="date" class="displayDate"><?php echo $commonUtils->timePost($comment['createddate']);?></span>
</div>
<div style="clear:both;"></div>
<?php }?>